/**
 * 求PI{(2^i+1)*(3^i),i=1...N}的个位数
 * 简单打表发现是9,5,5,5,5,...
 */
#include <bits/stdc++.h>
using namespace std;

using llt = long long;

int main(){
#ifndef ONLINE_JUDGE
    freopen("z.txt", "r", stdin);
#endif
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int nofkase; cin >> nofkase;
    while(nofkase--){
        llt n; cin >> n;
        cout << (1 == n ? 9 : 5) << endl;
    }
    return 0;
}